this.watchVideo = (function () {

  var watchVideo$1 = {};

  var logUtils$8 = {
    showing: false,
    show () {
      console.show ();
      this.showing = true;
    },
    hide () {
      console.hide ();
      this.showing = false;
    },
    log () {
      console.log.apply (console, arguments);
    },
  };

  var clickUtils$5 = {
    getRateX(x, w) {
      return parseInt(x * (device.width / (w || device.width)));
    },
    getRateY(y, h) {
      return parseInt(y * (device.height / (h || device.height)));
    },
    clickXY(x, y) {
      click(x, y);
    },
    clickXYZW(x, y, z, w, deltaX, deltaY) {
      var maxDeltaX = Math.abs(z - x) / 2;
      var maxDeltaY = Math.abs(w - y) / 2;
      deltaX = deltaX || 1;
      deltaY = deltaY || 1;
      deltaX = deltaX > maxDeltaX ? maxDeltaX - 2 : deltaX;
      deltaY = deltaY > maxDeltaY ? maxDeltaY - 2 : deltaY;
      this.clickXY(
        random(x + deltaX, z - deltaX),
        random(y + deltaY, w - deltaY)
      );
    },
    clickBounds(bounds, deltaX, deltaY) {
      var left = bounds.left;
      var right = bounds.right;
      var top = bounds.top;
      var bottom = bounds.bottom;
      this.clickXYZW(left, top, right, bottom, deltaX, deltaY);
    },
    clickPointMap(pointMap, deltaX, deltaY) {
      var point = pointMap[0];
      var width = pointMap[1];
      var height = pointMap[2];
      var x = this.getRateX(point[0], width);
      var y = this.getRateY(point[1], height);
      var z = this.getRateX(point[2], width);
      var w = this.getRateY(point[3], height);
      this.clickXYZW(x, y, z, w, deltaX, deltaY);
    },
    clickTextUI(TextUI, deltaX, deltaY) {
      this.clickBounds(TextUI.bounds(), deltaX, deltaY);
    },
    clickTextOCR(TextOCR, deltaX, deltaY) {
      this.clickBounds(TextOCR.bounds, deltaX, deltaY);
    },
  };

  var TEXT_MAX_SEARCH_TIME = 10000; //搜索控件时超时时间 http://doc.autoxjs.com/#/widgetsBasedAutomation?id=uiselectorfindonetimeout
  var logUtils$7 = logUtils$8;
  var textUtils$1 = {
    logBounds (bounds) {
      var left = bounds.left;
      var right = bounds.right;
      var top = bounds.top;
      var bottom = bounds.bottom;
      logUtils$7.log (left, right, top, bottom);
    },
    inScreen (TextUI) {
      var bounds = TextUI.bounds ();
      var left = bounds.left;
      var right = bounds.right;
      var top = bounds.top;
      var bottom = bounds.bottom;
      return (
        left > 0 && right < device.width && top < device.height && bottom > 0
      );
    },
    existsText (text$) {
      if (text (text$).exists ()) {
        var TextUI = text (text$).findOne (TEXT_MAX_SEARCH_TIME);
        return TextUI ? TextUI : false;
      } else {
        return false;
      }
    },
    existsTextInSceen (text$) {
      var TextUI = this.existsText (text$);
      return TextUI ? this.inScreen (TextUI) : false;
    },
  };

  var deviceUtils$2 = {
    lockScreen () {
      lockScreen ();
    },
    back () {
      back ();
    },
    home () {
      home ();
    },
    recents () {
      recents ();
    },
  };

  var gUtils$6 = {
    random (min, max) {
      return random (min, max);
    },
    sleep (start, end) {
      var duration = this.random (start, end) * 1000;
      sleep (duration);
    },
    sleepB (duration) {
      sleep (duration);
    },
    possible (start, end, scale) {
      var scale = scale || 100;
      var v = this.random (1, scale);
      return v >= start && v <= end;
    },
    hasExec (startTime) {
      var now = Date.now ();
      return parseInt ((now - startTime) / 1000);
    },
  };

  var logUtils$6 = logUtils$8;
  var deviceUtils$1 = deviceUtils$2;
  var clickUtils$4 = clickUtils$5;
  var gUtils$5 = gUtils$6;
  var pointMap$6 = {
    关闭所有应用: [[420, 2006, 660, 2246], 1080, 2340],
  };
  var appUtils$5 = {
    appName: null,
    openApp(appName) {
      this.appName = appName;
      var result = app.launchApp(appName);
      logUtils$6.log("打开：", appName, result ? "成功" : "失败");
      sleep(2 * 1000);
      return result;
    },
    closeRecent() {
      deviceUtils$1.home();
      sleep(2 * 1000);
      deviceUtils$1.recents();
      sleep(2 * 1000);
      if (["cannon", "evergo"].includes(device.product)) {
        swipe(
          device.width / 4 + device.width / 8 + device.width / 16,
          device.height / 2,
          device.width / 20,
          device.height / 2,
          200
        );
      } else {
        swipe(
          device.width / 2,
          device.height / 2,
          device.width / 2,
          device.height / 16,
          gUtils$5.random(300, 500)
        );
      }
      sleep(2 * 1000);
      deviceUtils$1.home();
      sleep(2 * 1000);
    },
    closeAll() {
      deviceUtils$1.home();
      sleep(2 * 1000);
      deviceUtils$1.recents();
      sleep(2 * 1000);
      clickUtils$4.clickPointMap(pointMap$6.关闭所有应用);
      sleep(2 * 1000);
    },
    checkInstall(appName) {
      return !!app.getPackageName(appName);
    },
    home(appName) {
      logUtils$6.log("将回到桌面");
      home();
      gUtils$5.sleep(10, 15);
      this.openApp(appName);
    },
  };

  var ocrCharMap$1 = {
    搜: ["嫂", "樓", "接", "楼"],
    赚: ["廉", "嫌", "賺", "兼"],
    看: ["着", "春"],
    文: ["女"],
    章: ["拿"],
    钱: ["线"],
    觉: ["党"],
    户: ["戶"],
    索: ["素"],
    开: ["升", "研"],
    金: ["全"],
    积: ["枳"],
    币: ["市"],
    现: ["現"],
    领: ["領", "颌", "颁"],
    读: ["渎"],
    额: ["額"],
    取: ["驭"],
    视: ["规", "初"],
    享: ["亨"],
    兑: ["兌"],
    提: ["堤"],
    体: ["休"],
    才: ["オ"],
    街: ["衔"],
    城: ["械"],
    间: ["闻"],
    来: ["來"],
    幕: ["慕"],
    十: ["+"],
    已: ["己"],
    己: ["已"],
    摄: ["攝"],
  };
  var ocrCharMap_1 = ocrCharMap$1;

  var logUtils$5 = logUtils$8;
  var ocrCharMap = ocrCharMap_1;

  if (!requestScreenCapture()) {
    toastLog("请求截图权限失败");
    exit();
  }
  function toArray(arrLike) {
    var array = [];
    for (var index = 0; index < arrLike.length; index++) {
      array.push(arrLike[index]);
    }
    return array;
  }
  function getCaptureImg() {
    var startTime = Date.now();
    var showing = logUtils$5.showing;
    if (showing) {
      logUtils$5.hide();
      sleep(0.1 * 1000);
    }
    var captureImg = captureScreen();
    if (showing) {
      logUtils$5.show();
    }
    if (!captureImg) {
      toastLog("截图失败");
    }
    var endTime = Date.now();
    var hasExec = (endTime - startTime) / 1000;
    if (hasExec > 1) {
      logUtils$5.log("GCI: 截图耗费-" + hasExec + "-s");
    }
    return captureImg;
  }
  function getOcrResults() {
    var captureImg = getCaptureImg();
    var ocrResults = toArray(gmlkit.ocr(captureImg, "zh").toArray(3));
    setTimeout(() => {
      captureImg.recycle();
    });
    return ocrResults;
  }
  var ocrUtils$2 = {
    getRegExpConfig(content) {
      var regExpStr = content
        .split("")
        .map(function (item) {
          var match = ocrCharMap[item];
          var piece = match
            ? "[" + match.concat(item).join("") + "]+"
            : "[" + item + "]+";
          return piece + `\\s*`;
        })
        .join("");
      return {
        text: content,
        regExp: new RegExp(regExpStr, "gi"),
      };
    },
    captureAndLog() {
      var ocrResults = getOcrResults();
      this.logOcrResults(ocrResults);
    },
    logOcrResults(ocrResults) {
      logUtils$5.log("LOR:", "\n", ocrResults.map((item) => item.text).join(","));
    },
    ocrResultsExist(ocrResults, regExpConfig) {
      for (var index = 0; index < ocrResults.length; index++) {
        var ocrResult = ocrResults[index];
        if (regExpConfig.regExp.test(ocrResult.text)) {
          return ocrResult;
        }
      }
      return false;
    },
    regExpConfigExist(ocrResults, regExpConfigs) {
      for (var index = 0; index < ocrResults.length; index++) {
        var ocrResult = ocrResults[index];
        for (var index2 = 0; index2 < regExpConfigs.length; index2++) {
          var regExpConfig = regExpConfigs[index2];
          if (regExpConfig.regExp.test(ocrResult.text)) {
            return ocrResult;
          }
        }
      }
      return false;
    },
    regExpConfigExistSome(ocrResults, regExpConfigs) {
      var results = [];
      for (var index = 0; index < ocrResults.length; index++) {
        var ocrResult = ocrResults[index];
        for (var index2 = 0; index2 < regExpConfigs.length; index2++) {
          var regExpConfig = regExpConfigs[index2];
          if (regExpConfig.regExp.test(ocrResult.text)) {
            results.push(ocrResult);
          }
        }
      }
      return results;
    },
    captureExistsText(content, logOcrResults, ignoreLog) {
      var regExpConfig = this.getRegExpConfig(content);
      var ocrResults = getOcrResults();
      var ocrResult = this.ocrResultsExist(ocrResults, regExpConfig);
      if (ocrResult) {
        if (!ignoreLog) {
          logUtils$5.log("CET:", "找到", regExpConfig.text, "/", ocrResult.text);
        }
        return ocrResult;
      } else {
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },
    captureExistsOneText(contents, logOcrResults, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      var ocrResults = getOcrResults();
      var regExpConfigs = contents.map((content) =>
        this.getRegExpConfig(content)
      );
      var ocrResult = this.regExpConfigExist(ocrResults, regExpConfigs);
      if (ocrResult) {
        if (!ignoreLog) {
          logUtils$5.log("CEOT:", "找到", contents.join(","), "/", ocrResult.text);
        }
        return ocrResult;
      } else {
        logUtils$5.log("CEOT:", "没找到", contents.join(","));
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },
    captureExistsSomeText(contents, logOcrResults, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      var ocrResults = getOcrResults();
      var regExpConfigs = contents.map((content) =>
        this.getRegExpConfig(content)
      );
      var results = this.regExpConfigExistSome(ocrResults, regExpConfigs);
      if (results.length > 0) {
        if (!ignoreLog) {
          logUtils$5.log(
            "CEOT:",
            "找到",
            contents.join(","),
            "/",
            results.map((item) => item.text).join(",")
          );
        }
        return results;
      } else {
        logUtils$5.log("CEOT:", "没找到", contents.join(","));
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },

    captureExistsAllText(contents, logOcrResults, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      var ocrResults = getOcrResults();
      var regExpConfigs = contents.map((content) =>
        this.getRegExpConfig(content)
      );
      var findResults = [];
      for (var index = 0; index < regExpConfigs.length; index++) {
        var regExpConfig = regExpConfigs[index];
        var ocrResult = this.ocrResultsExist(ocrResults, regExpConfig);
        if (ocrResult) {
          findResults.push(ocrResult);
        }
      }
      if (findResults.length == contents.length) {
        if (!ignoreLog) {
          logUtils$5.log(
            "CEAT:",
            "找到",
            "\n",
            contents.join(","),
            "\n",
            findResults.map((item) => item.text).join(",")
          );
        }
        return true;
      } else {
        logUtils$5.log("CEAT:", "没找到", contents.join(","));
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },
  };

  var logUtils$4 = logUtils$8;
  var clickUtils$3 = clickUtils$5;
  var textUtils = textUtils$1;
  var deviceUtils = deviceUtils$2;
  var appUtils$4 = appUtils$5;
  var gUtils$4 = gUtils$6;
  var ocrUtils$1 = ocrUtils$2;

  var utils = {
    logUtils: logUtils$4,
    clickUtils: clickUtils$3,
    textUtils: textUtils,
    deviceUtils: deviceUtils,
    appUtils: appUtils$4,
    gUtils: gUtils$4,
    ocrUtils: ocrUtils$1,
  };

  var {appUtils: appUtils$3, logUtils: logUtils$3, gUtils: gUtils$3} = utils;
  function App$3 (appName, config) {
    this.appName = appName;
    this.count = 0;
    this.maxCount = config.maxCount || null;
    this.interval = config.interval || null;
    this.autoClose = config.autoClose;
    this.isOverToday = false;
  }
  App$3.prototype.run = function () {};
  App$3.prototype.checkInstall = function () {
    var installed = appUtils$3.checkInstall (this.appName);
    if (!installed) {
      logUtils$3.log (this.appName, '未安装');
      return false;
    }
    return true;
  };
  App$3.prototype.checkInterval = function () {
    if (this.interval && this.lastEndTime) {
      var hasExec = gUtils$3.hasExec (this.lastEndTime);
      if (hasExec < this.interval) {
        logUtils$3.log (this.appName, '时间未到，跳过', this.interval, '|', hasExec);
        return false;
      }
    }
    return true;
  };
  App$3.prototype.checkCount = function () {
    if (this.maxCount && this.count > this.maxCount) {
      logUtils$3.log (this.appName, '超过次数，跳过', this.maxCount, '|', this.count);
      return false;
    }
    return true;
  };
  App$3.prototype.check = function () {
    if (!this.checkInstall ()) {
      return;
    }
    if (!this.checkInterval ()) {
      return;
    }
    if (!this.checkCount ()) {
      return;
    }
    if (this.isOverToday) {
      return;
    }
    return true;
  };
  App$3.prototype.exec = function () {};
  App$3.prototype.main = function () {
    if (!this.check ()) {
      return;
    }
    logUtils$3.log (this.appName, 'run', this.count);
    appUtils$3.openApp (this.appName);
    gUtils$3.sleep (6, 10);
    this.run (this.count);
    this.count++;
    this.lastEndTime = Date.now ();
    if (this.autoClose) {
      gUtils$3.sleep (2, 4);
      appUtils$3.closeRecent ();
    }
  };
  var App_1 = App$3;

  var base = {
    App: App_1,
  };

  var pointMap$5 = {
    首页: {
      推荐: [[137, 220, 306, 336], 1080, 2340],
      关注: [[0, 220, 137, 336], 1080, 2340],
      精选: [[306, 220, 443, 336], 1080, 2340],
      首页: [[0, 2165, 216, 2296], 1080, 2340],
      放映厅: [[216, 2165, 432, 2296], 1080, 2340],
      商城: [[648, 2165, 864, 2296], 1080, 2340],
      我的: [[864, 2165, 1080, 2296], 1080, 2340],
    },
  };

  var { gUtils: gUtils$2, clickUtils: clickUtils$2, logUtils: logUtils$2, appUtils: appUtils$2 } = utils;
  var { App: App$2 } = base;
  var pointMap$4 = pointMap$5;

  var xiGua$1 = new App$2("西瓜视频", {
    maxCount: 30,
    interval: 10 * 60,
    autoClose: true,
  });
  xiGua$1.run = function (count) {
    if (count > 3) {
      this.watchVideo(count);
    } else {
      gUtils$2.sleep(20, 60);
    }
  };
  xiGua$1.watchVideo = function (count) {
    var countIndex =
      count > 10 ? 5 + gUtils$2.random(1, 5) : 2 + gUtils$2.random(1, 2);
    logUtils$2.log("将看视频" + countIndex + "次");
    for (var index = 0; index < countIndex; index++) {
      gUtils$2.sleep(60, 120);
      this.nextVideo();
    }
  };
  xiGua$1.nextVideo = function () {
    if (gUtils$2.possible(1, 10)) {
      appUtils$2.home(this.appName);
      gUtils$2.sleep(2, 4);
    }
    logUtils$2.log("将看下一个视频");
    if (gUtils$2.possible(1, 20)) {
      logUtils$2.log("back()");
      back();
    } else {
      logUtils$2.log("点击首页");
      clickUtils$2.clickPointMap(pointMap$4.首页.首页);
    }
    gUtils$2.sleep(3, 6);
  };
  var watchVideo = xiGua$1;

  var pointMap$3 = {
    首页: {
      追剧: {
        追剧: [[342, 125, 540, 193], 1080, 2340],
        1: [[45, 358, 360, 832], 1080, 2340],
        2: [[383, 358, 697, 832], 1080, 2340],
        3: [[720, 358, 1035, 832], 1080, 2340],
        4: [[45, 1013, 360, 1487], 1080, 2340],
        5: [[383, 1013, 697, 1487], 1080, 2340],
        6: [[720, 1013, 1035, 1487], 1080, 2340],
        7: [[45, 1668, 360, 2141], 1080, 2340],
        8: [[383, 1668, 697, 2141], 1080, 2340],
        9: [[720, 1668, 1035, 2141], 1080, 2340],
      },
      推荐: [[738, 125, 936, 193], 1080, 2340],
    },
  };

  var pointMap_1$1 = pointMap$3;

  var { clickUtils: clickUtils$1, gUtils: gUtils$1, logUtils: logUtils$1, appUtils: appUtils$1 } = utils;
  var { App: App$1 } = base;
  var pointMap$2 = pointMap_1$1;

  var daiShuDD = new App$1("袋鼠点点短视频", {
    maxCount: 30,
    interval: 10 * 60,
    autoClose: true,
  });

  daiShuDD.run = function (count) {
    gUtils$1.sleep(5, 10);
    logUtils$1.log("将点击 推荐");
    clickUtils$1.clickPointMap(pointMap$2.首页.推荐);
    this.watchVideo(count);
  };
  daiShuDD.watchVideo = function (count) {
    logUtils$1.log("第" + count + "次打开袋鼠点点");
    for (var index = 0; index < 5; index++) {
      logUtils$1.log("第" + (index + 1) + "次看视频");
      gUtils$1.sleep(30, 60);
      if (gUtils$1.possible(1, 10)) {
        appUtils$1.home(this.appName);
      }
    }
  };

  var pointMap$1 = {
    首页: {
      1: [[27 + 5, 347, 358, 810], 1080, 2340],
      2: [[374 + 5, 347, 705, 810], 1080, 2340],
      3: [[721 + 5, 347, 1052, 810], 1080, 2340],
      4: [[27 + 5, 973, 358, 1436], 1080, 2340],
      5: [[374 + 5, 973, 705, 1436], 1080, 2340],
      6: [[721 + 5, 973, 1052, 1436], 1080, 2340],
      7: [[27 + 5, 1599, 358, 2062], 1080, 2340],
      8: [[374 + 5, 1599, 705, 2062], 1080, 2340],
      9: [[721 + 5, 1599, 1052, 2062], 1080, 2340],
    },
  };

  var pointMap_1 = pointMap$1;

  var {
    clickUtils,
    gUtils,
    logUtils,
    ocrUtils,
    appUtils,
  } = utils;
  var { App } = base;
  var pointMap = pointMap_1;

  var hongGuoMF = new App("红果免费短剧", {
    maxCount: 30,
    interval: 10 * 60,
    autoClose: true,
  });

  hongGuoMF.run = function (count) {
    gUtils.sleep(15, 20);
    var OcrText = ocrUtils.captureExistsOneText(["选集"]);
    if (!OcrText) {
      var index = gUtils.random(1, 9);
      logUtils.log("将点击首页第" + index + "类视频");
      clickUtils.clickPointMap(pointMap.首页[index]);
      gUtils.sleep(2, 3);
    }
    this.watchVideo(count);
  };
  hongGuoMF.watchVideo = function (count) {
    logUtils.log("第" + count + "红果免费短剧");
    for (var index = 0; index < 5; index++) {
      logUtils.log("第" + (index + 1) + "次看视频");
      gUtils.sleep(60, 90);
      if (gUtils.possible(1, 10)) {
        appUtils.home(this.appName);
      }
    }
  };

  var xiGua = watchVideo;

  function main(appName, duration) {
    if (appName && appName.indexOf("西瓜") != -1) {
      xiGua.watch;
    }
  }
  Wang.main = main;

  return watchVideo$1;

})();
